package com.QiLin.service.impl;

import com.QiLin.dao.LinDao;
import com.QiLin.domain.User;
import com.QiLin.service.LinService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Service
public class LinImpl implements LinService {

    @Resource
    LinDao linDao;
    public boolean enterService(User userb, HttpSession session) {
       User us= linDao.enterDao(userb);
       session.setAttribute("name",us.getQname());
       session.setAttribute("user",us.getUser());
       if(us!=null){
           return true;
       }else{
           return false;
       }
    }

    @Override
    public void signinService(User userb) {


       int qlin= linDao.signinDao(userb);
       if(qlin==1){
           System.out.println("创建成功");
       }else{
           System.out.println("创建失败");
       }
    }

    @Override
    public boolean DetectionRepetition(String name,String user) {
       User boo= linDao.DetectionRepetitionDao(name,user);
       System.out.println(boo);
       if(boo!=null){
           return false;
       }else{
           return true;
       }
    }

    @Override
    public User GetDataService(HttpSession session) {
        User q=new User();
        q.setQname((String) session.getAttribute("name"));
        return q;
    }

    @Override
    public boolean LengthDetection(String user, String password) {
        user.length();
        if(user.length()<=10 && password.length()<=12){
            return true;
        }else{
            return false;
        }
    }
}
